package com.linkage.user.service;

import java.util.List;
import java.util.UUID;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkage.user.pojo.User;
import com.linkage.user.repository.UserRepository;
import com.linkage.user.repository.UserRepositoryMapper;

@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;
    
    @Autowired
    private UserRepositoryMapper userRepositoryMapper;

    public List<User> queryAll() {
        return this.userRepository.queryAll();
    }

    public void save(User user) {
        //user.setPkId(UUID.randomUUID().toString());
        this.userRepository.save(user);
    }

    public void update(User user) {
        this.userRepository.update(user);
    }

    public void delete(String userId) {
        this.userRepository.delete(userId);
    }

    public User loadOne(String userId) {
        return this.userRepository.loadOne(userId);
    }
    
    public User loadByLoginName(@Param("userName") String userName){
        return this.userRepositoryMapper.loadByLoginName(userName);
    }
    
    public void registOne(User user) {
		//user.setUserId(UUID.randomUUID().toString());
		this.userRepository.registOne(user);
	}
}
